package daily.kou2022_0104;

public class Num141 {
    //141. 环形链表
    public boolean hasCycle(ListNode head) {
        //定义快慢指针
        ListNode fast=head;
        ListNode slow=head;
        while (fast!=null&&fast.next!=null){
            fast=fast.next.next;
            slow=slow.next;
            //最终会相遇
            if(fast==slow){
                return true;
            }
        }
       return false;
    }
}
